package cn.tedu.movie.controller;


import cn.tedu.movie.bean.AlipayBean;
import cn.tedu.movie.service.PayService;
import cn.tedu.movie.util.Utils;
import com.alipay.api.AlipayApiException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.resource.HttpResource;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("/order")
public class OrderController {
    @Autowired
    private PayService payService;//调用支付服务
    @PostMapping("/alipay")
    public String alipay(String out_trade_no, String subject, String total_amount, String body,Integer order_id) throws AlipayApiException, AlipayApiException {
        Thread t= Utils.getThreadByName(order_id+"");
        t.suspend();

        return payService.aliPay(new AlipayBean()
                .setBody(body)
                .setOut_trade_no(out_trade_no)
                .setTotal_amount(new StringBuffer().append(total_amount))
                .setSubject(subject));
    }

}

